package day240530.pro.storer;

import day240530.pro.until.CustomResult;

import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.List;

public class StorerToFile implements Storer {
    private static final String FILE = "src/day240530/pro/until/repository.date";
    @Override
    public void store(List<CustomResult> results) {
        try (
                PrintWriter pw = new PrintWriter(new FileWriter(FILE));
        ) {
            for (CustomResult cr : results) {
                pw.println(cr.getTitle());
                pw.println(cr.getUrl());
                pw.println(cr.getCreatedAt());
                pw.println(cr.getUpdateAt());
                pw.println("--- --- ---");
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
